package com.example.orderform.dao;

import com.example.orderform.vo.Comments;
import com.example.orderform.vo.CommentsS2;
import com.example.orderform.vo.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
@Mapper
public interface EvaluateMapper {

    @Select("select * from order_copy1 where orderstatus='评价' and userid=${userid} LIMIT #{q},#{j}")
    List<Order>evaluatecha(int q,int j,int userid);

    @Select("select count(*) from order_copy1 where orderstatus='评价' and userid=#{userid}")
    int evalcha(int userid);

    @Select("select * from order_copy1 where orderid=${orderid}")
    Order evaorderxq(int orerid);


    //新增
    @Insert("insert into evaluate values('${orderid}','${evaluationgrade}','${evaluationcommodity}')")
    int xzdd(int orderid,String evaluationgrade,String evaluationcommodity);

    @Update("update order_copy1 set orderstatus='交易成功' where orderid=#{orderid} ")
    int gad(int orderid);


    @Select("SELECT * FROM `t_user_content` where User_id=#{userid} and commodity_id=#{spid}")
    List<Comments> commentsS(int userid,int spid);

    @Select("SELECT * FROM `t_user_reply` where User_id=#{userid} and commodity_id=#{spid}")
    List<CommentsS2> commentsS2(int userid, int spid);

    @Select("SELECT * FROM `evaluate` ")
    List<Comments> plht();

    @Insert("INSERT INTO `t_user_content` (`User_id`, `commodity_id`, `comment_content`, `message_status`, `comment_grade`, `comment_time`) VALUES (#{User_id}, #{commodity_id},#{comment_content},#{message_status},#{comment_grade}, #{comment_time})")
    int waipinl(int User_id,int commodity_id,String comment_content,int message_status,int comment_grade , Date comment_time);

    @Select("SELECT id from t_user_content where User_id=#{User_id} and commodity_id=#{commodity_id} and comment_content=#{comment_content} and message_status=#{message_status} and comment_grade=#{comment_grade} and comment_time=#{comment_time}")
    int idd(int User_id,int commodity_id,String comment_content,int message_status,int comment_grade , Date comment_time);

    @Insert("INSERT INTO `t_user_reply` ( `commodity_id`, `User_id`, `comment_id`, `reply_content`, `comment_time`) VALUES (#{commodity_id}, #{User_id}, #{comment_id}, #{reply_content}, #{comment_time})")
    int neipinl(int commodity_id,int User_id,int comment_id,String reply_content,Date comment_time);


    @Select("SELECT spid FROM `order_copy1` where orderid=#{orderid}")
    int selectsp(int orderid);

}
